import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '标物名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '标物类别',
    align: "center",
    dataIndex: 'type'
  },
  {
    title: '标物批号',
    align: "center",
    dataIndex: 'batch'
  },
  // {
  //   title: '纯度/标准',
  //   align: "center",
  //   dataIndex: 'purity'
  // },
  {
    title: '生产厂家',
    align: "center",
    dataIndex: 'factory'
  },
  // {
  //   title: '规格',
  //   align: "center",
  //   dataIndex: 'specs'
  // },
  // {
  //   title: '入库数量',
  //   align: "center",
  //   dataIndex: 'number'
  // },
  // {
  //   title: '单位',
  //   align: "center",
  //   dataIndex: 'units_dictText'
  // },
  {
    title: '有效期',
    align: "center",
    dataIndex: 'restrictedDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  // {
  //   title: '证书',
  //   align: "center",
  //   dataIndex: 'certificate',
  //   slots: { customRender: 'fileSlot' },
  // },
  // {
  //   title: '颜色性状',
  //   align: "center",
  //   dataIndex: 'properties_dictText'
  // },
  // {
  //   title: '标识标签',
  //   align: "center",
  //   dataIndex: 'tag_dictText'
  // },
  // {
  //   title: '包装',
  //   align: "center",
  //   dataIndex: 'packages_dictText'
  // },
  // {
  //   title: '存放地点',
  //   align: "center",
  //   dataIndex: 'storagePlace'
  // },
  {
    title: '购买日期',
    align: "center",
    dataIndex: 'buyDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '标物状态',
    align: "center",
    dataIndex: 'status_dictText'
  },
  // {
  //   title: '用途',
  //   align: "center",
  //   dataIndex: 'purpose'
  // },
  // {
  //   title: '备注',
  //   align: "center",
  //   dataIndex: 'remark'
  // },
  {
    title: '实物图片',
    align: "center",
    dataIndex: 'picture',
    customRender: render.renderImage,
  },
  {
    title: '当前库存',
    align: "center",
    dataIndex: 'inventoryNow'
  },
  {
    title: '单位',
    align: "center",
    dataIndex: 'unity_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "标物名称",
    field: 'name',
    component: 'JDictSelectTag',
    componentProps:{
    },
    colProps: {span: 6},
  },
  {
    label: "标物类别",
    field: 'type',
    component: 'JSearchSelect',
    componentProps:{
      dict: ",,"
    },
    colProps: {span: 6},
  },
  {
    label: "生产厂家",
    field: 'factory',
    component: 'JSearchSelect',
    componentProps:{
      dict: ",,"
    },
    colProps: {span: 6},
  },
  {
    label: "有效期",
    field: "restrictedDate",
    component: 'RangePicker',
    colProps: {span: 6},
  },
  {
    label: "购买日期",
    field: "buyDate",
    component: 'RangePicker',
    colProps: {span: 6},
  },
  {
    label: "标物状态",
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "chemical_status"
    },
    colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '标物名称',
    field: 'name',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: ""
    },
    dynamicRules: () => {
      return [
              { required: true, message: '请输入标物名称!'},
             ];
    },
  },
  {
    label: '标物类别',
    field: 'type',
    component: 'JSearchSelect',
    componentProps:{
      dict: ""
    },
    dynamicRules: () => {
      return [
              { required: true, message: '请输入标物类别!'},
             ];
    },
  },
  {
    label: '标物批号',
    field: 'batch',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入标物批号!'},
             ];
    },
  },
  {
    label: '纯度/标准',
    field: 'purity',
    component: 'Input',
    dynamicRules: () => {
      return [
              { required: true, message: '请输入纯度/标准!'},
             ];
    },
  },
  {
    label: '生产厂家',
    field: 'factory',
    component: 'JSearchSelect',
    componentProps:{
      dict: ""
    },
  },
  {
    label: '规格',
    field: 'specs',
    component: 'Input',
  },
  {
    label: '入库数量',
    field: 'number',
    component: 'InputNumber',
  },
  {
    label: '单位',
    field: 'units',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "units"
    },
  },
  {
    label: '有效期',
    field: 'restrictedDate',
    component: 'DatePicker',
  },
  {
    label: '证书',
    field: 'certificate',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '颜色性状',
    field: 'properties',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "character"
    },
  },
  {
    label: '标识标签',
    field: 'tag',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "appearance"
    },
  },
  {
    label: '包装',
    field: 'packages',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "appearance"
    },
  },
  {
    label: '存放地点',
    field: 'storagePlace',
    component: 'Input',
  },
  {
    label: '购买日期',
    field: 'buyDate',
    component: 'DatePicker',
  },
  {
    label: '标物状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "chemical_status"
    },
  },
  {
    label: '用途',
    field: 'purpose',
    component: 'InputTextArea',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '实物图片',
    field: 'picture',
    component: 'JImageUpload',
    componentProps:{
    },
  },
  {
    label: '当前库存',
    field: 'inventoryNow',
    component: 'InputNumber',
  },
  {
    label: '单位',
    field: 'unity',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "units"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];
